package acm.pta6;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class 抢红包 {
    /**
     * 先用哈希表，将每个人对应的钱设置好
     */
    public static void main(String[] args) {
        Reader sc=new Reader();
        int n = sc.nextInt();
//        Node[] people=new Node[n+1];
        int[][] people=new int[n+1][3];   //0:id,1：总金额，2：红包个数
//        people[0]=new Node(-1);
//        people[0].money=Integer.MIN_VALUE;
        for (int i = 1; i <= n ; i++) {
            people[i]=new int[]{i,0,0};
        }
        for (int i = 1; i <= n ; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int id = sc.nextInt();
                int money = sc.nextInt();
                people[id][2]++;
                people[id][1]+=money;
                people[i][1]-=money;
            }
        }
        List<int[]> nodes = new ArrayList<>(Arrays.asList(people));
        nodes.remove(0);
        nodes.sort((o1, o2) -> {
            if (o1[1]== o2[1]){
                if (o1[2]== o2[2]){
                    return o1[0]-o2[0];
                }
                return o2[2]-o1[2];
            }
            return o2[1]- o1[1];
        });
        for (int[] p : nodes) {
            System.out.println(p[0]+" "+String.format("%.2f",p[1]/100.0));
        }
    }
    static class Node{
        int id;
        int count;
        int money;

        public Node(int id) {
            this.id = id;
        }
    }
    static class Reader {
        private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer tokenizer = new StringTokenizer("");

        private String innerNextLine() {
            try {
                return reader.readLine();
            } catch (IOException ex) {
                return null;
            }
        }

        public boolean hasNext() {
            while (!tokenizer.hasMoreTokens()) {    //内存中没有
                String nextLine = innerNextLine();
                if (nextLine == null) {     //且没有下一行
                    return false;
                }
                tokenizer = new StringTokenizer(nextLine);  //读入一行
            }
            return true;
        }

        public String nextLine() {
            tokenizer = new StringTokenizer("");    //清空内存中的字符
            return innerNextLine();
        }

        public String next() {
            hasNext();
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble(){
            return Double.parseDouble(next());
        }

    }
}
